package com.gw.vip.server.service.dao_service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gw.vip.common.exception.ExceptionEnums;
import com.gw.vip.common.exception.ServiceException;
import com.gw.vip.server.dao.SysCapitalTypeMapper;
import com.gw.vip.server.po.SysCapitalType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author GW
 * @description
 * @since 2022-05-05
 */
@Service
@Slf4j
public class SysCapitalTypeService extends ServiceImpl<SysCapitalTypeMapper, SysCapitalType> {
    public Integer getPayOrder(List<SysCapitalType> sysCapitalTypeList, String capitalId){
        SysCapitalType sysCapitalType=null;
        for (SysCapitalType capitalType:sysCapitalTypeList){
            if (capitalType.getId().equals(capitalId)){
                sysCapitalType = capitalType;
                break;
            }
        }
        if (sysCapitalType==null){
            log.error("资金类型【{}】不存在！", capitalId);
            throw new ServiceException(ExceptionEnums.ERROR_SETTING, "资金类型不存在！");
        }
        return sysCapitalType.getSequence();
    }
}
